Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

monotonic-timestamp

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

monotonic-timestamp

Monotonically increasing timestamp.

  • 0.0.9
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

monotonic-timestamp

Monotonically increasing timestamp.

<img src=https://secure.travis-ci.org/'Dominic Tarr'/monotonic-timestamp.png?branch=master>

This is NOT a accurate representation of the time. Since js only measures time as ms, if you call Date.now() twice quickly, it's possible to get two identical time stamps.

monotonic-timestamp fixes that problem! (crudely)

Example

var timestamp = require('monotonic-timestamp')

console.log(timestamp())
console.log(timestamp())
console.log(timestamp())
console.log(timestamp())
console.log(timestamp())

subsequent calls to timestamp() are ALWAYS strictly ordered.

byte optimizations

My precious bytes! wasted on your timestamp!

pack it into a string!

timestamp().toString(36) 

if you want a constant-length string, you can use monotonic-timestamp-base36

of course, if you are using a binary protocol, it will be cheaper to use the float...

##TODO

syncronize network time.

License

MIT

FAQs

Package last updated on 19 Aug 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc